﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace VTNT.Service.Data.Sys
{
    public class CDataControler
    {
        private static string[] CrossDomain =
        {
            "localhost",
            "vtnt.vn",
            "binhphat.vtnt.vn"
        };
        public static bool ValidateRequest(string InputValue)
        {
            AddCrossDomainHeader();
            return true;
        }

        private static void AddCrossDomainHeader()
        {
            string referrerUrl = "";
            if (HttpContext.Current.Request.UrlReferrer != null)
            {
                referrerUrl = HttpContext.Current.Request.UrlReferrer.Scheme + "://" + HttpContext.Current.Request.UrlReferrer.Authority;
            }
            else
            {

                if (HttpContext.Current.Request.QueryString["referrer"] != null)
                {

                    referrerUrl = HttpContext.Current.Request.QueryString["referrer"].ToString();
                }
                else
                {
                    referrerUrl = "http://localhost";
                }
            }


            HttpContext.Current.Response.AppendHeader("Access-Control-Allow-Origin", referrerUrl);


        }

        public static string HtmlDecode(string xmlString)
        {
            return System.Web.HttpUtility.HtmlDecode(xmlString);
        }

        public static string HtmlEndCode(string xmlString)
        {
            return System.Web.HttpUtility.HtmlEncode(xmlString);
        }

    }
}